﻿package mortal.game.view.common.tooltip
{
    import com.gengine.global.*;
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.game.manager.*;
    import mortal.game.view.common.*;

    public class ClickToolTip extends Tooltip
    {
        protected var _closeBtn:GButton;

        public function ClickToolTip()
        {
            this.addCloseButton();
            return;
        }// end function

        protected function addCloseButton() : void
        {
            this._closeBtn = UIFactory.gLoadedButton("CloseButtonSmall", 0, 2, 22, 22, this);
            this._closeBtn.focusEnabled = true;
            this._closeBtn.name = "Window_Btn_Close";
            this._closeBtn.addEventListener(MouseEvent.CLICK, this.closeBtnClickHandler);
            return;
        }// end function

        public function show(param1:int, param2:int) : void
        {
            var _loc_3:* = this.width;
            var _loc_4:* = this.height;
            var _loc_5:* = Global.stage.stageWidth;
            var _loc_6:* = Global.stage.stageHeight;
            var _loc_7:* = param1 + 4;
            var _loc_8:* = param2 + 4;
            var _loc_9:Boolean = true;
            if (_loc_7 + _loc_3 >= _loc_5)
            {
                _loc_9 = false;
                _loc_7 = _loc_5 - _loc_3 - 4;
            }
            if (_loc_8 + _loc_4 >= _loc_6)
            {
                _loc_8 = _loc_6 - _loc_4 - 4;
            }
            if (_loc_7 < 4)
            {
                _loc_7 = 4;
            }
            if (_loc_8 < 4)
            {
                _loc_8 = 4;
            }
            this.x = _loc_7;
            this.y = _loc_8;
            if (this.parent == null)
            {
                LayerManager.toolTipLayer.addChild(this);
            }
            this.addChild(this._closeBtn);
            positionChanged();
            leftShowMode = _loc_9;
            return;
        }// end function

        public function hide() : void
        {
            DisplayUtil.removeMe(this);
            return;
        }// end function

        override public function set data(param1) : void
        {
            super.data = param1;
            this._closeBtn.x = this.width - this._closeBtn.width - 2;
            return;
        }// end function

        protected function closeBtnClickHandler(event:MouseEvent) : void
        {
            this.hide();
            return;
        }// end function

    }
}
